package com.reform.controller.phase;


import com.reform.res.Result;
import com.reform.service.IBatchPhaseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.sql.SQLException;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author mortale
 * @since 2021-08-06
 */
@Api(tags = "BatchPhaseController")
@RestController
@RequestMapping("/batch-phase")
public class BatchPhaseController {

    @Autowired
    IBatchPhaseService batchPhaseService;

    @ApiOperation(value = "通过batchId、phaseId删除所有阶段检查信息")
    @PostMapping("/deleteBatchPhase")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "batchId", value = "批次编号", paramType = "query", dataTypeClass = String.class, required = true),
            @ApiImplicitParam(name = "phaseId", value = "阶段检查编号", paramType = "query", dataTypeClass = String.class, required = true),
    })
    public Result deleteBatchPhase(String batchId, String phaseId) throws SQLException {
        return batchPhaseService.deleteBatchPhase(batchId, phaseId);
    }

    @ApiOperation(value = "添加阶段检查信息")
    @PostMapping("/insertBatchPhase")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "phaseId", value = "阶段检查编号", paramType = "query", dataTypeClass = String.class, required = true),
            @ApiImplicitParam(name = "batchIdInfo", value = "batchId信息JSON数组", paramType = "query", dataTypeClass = String.class, required = true),
    })
    public Result insertBatchPhase(String phaseId, String batchIdInfo) throws SQLException {
        return batchPhaseService.insertBatchPhase(phaseId, batchIdInfo);
    }

    @ApiOperation(value = "批量删除阶段检查信息")
    @PostMapping("/deleteBatchPhases")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "phaseId", value = "阶段检查编号", paramType = "query", dataTypeClass = String.class, required = true),
            @ApiImplicitParam(name = "batchIdInfo", value = "batchId信息JSON数组", paramType = "query", dataTypeClass = String.class, required = true),
    })
    public Result deleteBatchPhases(String phaseId, String batchIdInfo) throws SQLException {
        return batchPhaseService.deleteBatchPhases(phaseId, batchIdInfo);
    }

}
